package com.huabo.contract.mysql.mapper;

import com.hbfk.util.DateUtil;
import com.huabo.contract.mysql.entity.TblAttachmentMySql;

public class TblAttachmentMySqlMapperSqlConfig {

    public String add(TblAttachmentMySql att) {
        StringBuffer column = new StringBuffer("INSERT INTO TBL_ATTACHMENT (");
        StringBuffer value = new StringBuffer(" VALUES (");

        if(att.getAttname() != null && !"".equals(att.getAttname())) {
            column.append(",ATTNAME");
            value.append(",'"+att.getAttname()+"'");
        }
        if(att.getAttpath() != null && !"".equals(att.getAttpath())) {
            column.append(",ATTPATH");
            value.append(",'"+att.getAttpath()+"'");
        }
        if(!"".equals(att.getAttsize())) {
            column.append(",ATTSIZE");
            value.append(",'"+att.getAttsize()+"'");
        }
        if(att.getMemo() != null && !"".equals(att.getMemo())) {
            column.append(",MEMO");
            value.append(",'"+att.getMemo()+"'");
        }
        if(att.getUploadtime() != null && !"".equals(att.getUploadtime())) {
            column.append(",UPLOADTIME");
            value.append(",TO_DATE('"+ DateUtil.parseDate(att.getUploadtime(),"yyyy-MM-dd HH:mm:ss") +"', 'YYYY-MM-DD HH24:MI:SS')");
        }
        if(att.getUploader() != null && !"".equals(att.getUploader())) {
            column.append(",UPLOADER");
            value.append(",'"+att.getUploader()+"'");
        }
        if(att.getIspythonflag() != null && !"".equals(att.getIspythonflag())) {
            column.append(",ISPYTHONFLAG");
            value.append(",'"+att.getIspythonflag()+"'");
        }

        column.append(")");
        value.append(")");
        String sql = column.toString()+value.toString();
        return sql;
    }
}
